//
//  MSNavigationController.m
//  欢乐美食
//
//  Created by 遇水 on 15/5/28.
//  Copyright (c) 2015年 遇水. All rights reserved.
//  此类中主要是菜单的设置等等问题

#import "MSNavigationController.h"
#import "UIView+Extension.h"
#import "UIBarButtonItem+Extension.h"

@interface MSNavigationController ()

@end

@implementation MSNavigationController



-(void)viewWillAppear:(BOOL)animated{
    
}
- (void)viewDidLoad {
    [super viewDidLoad];

}




+(void)initialize{
    //设置UINavigationBarTheme主题
   // [self setNavigationTheme];
    
    //设置UIBarButtonItem的主题
//    [self setBarButtonItemTheme];

}
/**
 *  改变navigationbar的主题
 *
 */
+(void)setNavigationTheme{
    UINavigationBar *appearance = [UINavigationBar appearance];
    
    //设置字体属性
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSForegroundColorAttributeName] = [UIColor whiteColor];
    attr[NSFontAttributeName] = [UIFont systemFontOfSize:20];
    [appearance setTitleTextAttributes:attr];
    
}


+(void)setBarButtonItemTheme{
    UIBarButtonItem *appearance = [UIBarButtonItem appearance];
    //设置字体属性
    NSMutableDictionary *attri = [NSMutableDictionary dictionary];
    attri[NSForegroundColorAttributeName] = [UIColor whiteColor];
    
    [appearance setTitleTextAttributes:attri forState:UIControlStateNormal];
    
    
    
    NSMutableDictionary *highTextAttrs = [NSMutableDictionary dictionaryWithDictionary:attri];
    highTextAttrs[UITextAttributeTextColor] = [UIColor redColor];
    [appearance setTitleTextAttributes:highTextAttrs forState:UIControlStateHighlighted];
    
}


-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        //说明已经有控制器了
        viewController.hidesBottomBarWhenPushed = YES;
        
        //修改baritem
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"back-icon" target:self action:@selector(back)];
    }
    
    [super pushViewController:viewController animated:animated];
    
}

-(void)back{
    [self popViewControllerAnimated:YES];
}

@end
